# This Python file uses the following encoding: utf-8

#from django.contrib.auth.models import User
from missatgeria.models import Missatge
from django.utils.datetime_safe import datetime


#-------------------------------------------------------------------------------------
def connecta():
    
    from django.db.models.signals import post_save, pre_save, pre_delete
    
    #incidencia
    pre_delete.connect(Missatge_pre_delete, sender= Missatge)
    pre_save.connect(Missatge_pre_save, sender = Missatge )
    post_save.connect(Missatge_post_save, sender = Missatge )

#-------------EXPULSIONS DEL CENTRE-------------------------------------------------------------      

def Missatge_clean(instance):
    #
    #pre-save
    #
    instance.data = datetime.now()
    pass

def Missatge_pre_save(sender, instance, **kwargs):
    Missatge_clean( instance  )
    pass

def Missatge_post_save(sender, instance, created, **kwargs):
    pass

def Missatge_pre_delete( sender, instance, **kwargs):
    pass

